package com.xiaoer.studyenglishdemo.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.xiaoer.studyenglishdemo.R;
import com.xiaoer.studyenglishdemo.bean.WordBean;
import com.xiaoer.studyenglishdemo.data.WordsDB;
import com.xiaoer.studyenglishdemo.util.WordsLoader;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class StudyIdeaListActivity extends AppCompatActivity {
    Button btn1, btn2, btn3, btn4, btn5, btn6;
    private WordBean.WORD_LEVEL wordLevel;

    public static void startMe(Context context, WordBean.WORD_LEVEL wordLevel) {
        Intent intent = new Intent(context, StudyIdeaListActivity.class);
        intent.putExtra("wordLevel", wordLevel.name());
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        wordLevel = WordBean.WORD_LEVEL.valueOf(getIntent().getStringExtra("wordLevel"));
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_study_idea_list);

        btn1 = findViewById(R.id.btn1);
        btn2 = findViewById(R.id.btn2);
        btn3 = findViewById(R.id.btn3);
        btn4 = findViewById(R.id.btn4);
        btn5 = findViewById(R.id.btn5);
        btn6 = findViewById(R.id.btn6);

        // 单词学习
        btn1.setOnClickListener(v -> {
            WordsDetailActivity.startMe(this, WordsLoader.getSelLevelWords(StudyIdeaListActivity.this, wordLevel, WordBean.STUDY_TYPE.WORDS));
        });

        // 词根学习
        btn2.setOnClickListener(v -> {
            WordsDetailActivity.startMe(this, WordsLoader.getSelLevelWords(StudyIdeaListActivity.this, wordLevel, WordBean.STUDY_TYPE.WORD_ROOT));
        });

        // 词组学习
        btn3.setOnClickListener(v -> {
            WordsDetailActivity.startMe(this, WordsLoader.getSelLevelWords(StudyIdeaListActivity.this, wordLevel, WordBean.STUDY_TYPE.PHRASES));
        });

        // 语境学习
        btn4.setOnClickListener(v -> {
            WordsDetailActivity.startMe(this, WordsLoader.getSelLevelWords(StudyIdeaListActivity.this, wordLevel, WordBean.STUDY_TYPE.LINGUISTIC_CONTEXT));
        });

        // 例句学习
        btn5.setOnClickListener(v -> {
            WordsDetailActivity.startMe(this, WordsLoader.getSelLevelWords(StudyIdeaListActivity.this, wordLevel, WordBean.STUDY_TYPE.Example));
        });

        // 其他单词学习
        btn6.setOnClickListener(v -> {
            WordsDetailActivity.startMe(this, WordsLoader.getSelLevelWords(StudyIdeaListActivity.this, wordLevel, WordBean.STUDY_TYPE.OTHER_TYPE));
        });
    }
}